feat(pm): add why command for dependency analysis#272
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
8bc85e5 to
89b1746
Compare
89b1746 to
f47b47c
Compare
8be19c4 to
c64a1db
Compare
c64a1db to
9e246ff
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a vite why command (with alias vite explain) that provides a unified interface for querying package dependencies across different package managers (pnpm, npm, yarn). The command automatically detects the package manager and translates the command to the appropriate syntax, supporting various options like JSON output, workspace filtering, and dependency type filtering.
- Adds new
whycommand to CLI that adapts to detected package manager (pnpm/npm/yarn) - Implements package manager-specific command resolution with feature detection and warnings
- Adds comprehensive test coverage with snapshot tests for pnpm10, npm10, and yarn4
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| rfcs/why-package-command.md | Complete RFC documentation for the vite why command feature |
| packages/tools/src/utils.ts | Adds regex to normalize npm registry domains in test output |
| packages/tools/src/tests/utils.spec.ts | Test case for registry domain replacement |
| packages/tools/src/tests/snapshots/utils.spec.ts.snap | Expected output snapshot for registry domain test |
| packages/global/snap-tests/command-why-* | Comprehensive snapshot tests for why command across package managers |
| packages/cli/binding/src/commands/why.rs | New WhyCommand implementation for CLI binding |
| packages/cli/binding/src/commands/mod.rs | Module export for why command |
| packages/cli/binding/src/cli.rs | CLI argument parsing and command dispatch for why |
| crates/vite_install/src/commands/why.rs | Core implementation of why command with package manager resolution |
| crates/vite_install/src/commands/mod.rs | Module export for why command in install crate |
| packages/global/snap-tests/cli-helper-message/snap.txt | Updated help output to include why command |
| packages/cli/snap-tests/exit-non-zero-on-cmd-not-exists/snap.txt | Updated error message to include why/explain in subcommands |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9e246ff to
6087892
Compare
6087892 to
86831a0
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

TL;DR
Added a new
vite whycommand (withexplainalias) that shows why a package is installed in your project by automatically adapting to the detected package manager (pnpm/npm/yarn).What changed?
whycommand to the CLI that shows dependency relationships for specified packagesHow to test?
Why make this change?
This command helps developers understand dependency relationships, audit package usage, and debug dependency tree issues. Previously, users had to remember package manager-specific commands (
pnpm why,npm explain,yarn why), but now they can use a single unified interface that automatically adapts to the detected package manager. This is especially useful in monorepos or when switching between projects with different package managers.